import request from '@/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/position/knowledgeClassification/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    },
  });
};

export const getDetail = id => {
  return request({
    url: '/position/knowledgeClassification/detail',
    method: 'get',
    params: {
      id,
    },
  });
};

export const remove = ids => {
  return request({
    url: '/position/knowledgeClassification/remove',
    method: 'post',
    params: {
      ids,
    },
  });
};

export const add = row => {
  return request({
    url: '/position/knowledgeClassification/save',
    method: 'post',
    data: row,
  });
};

export const update = row => {
  return request({
    url: '/position/knowledgeClassification/update',
    method: 'post',
    data: row,
  });
};

export const publish = id => {
  return request({
    url: '/position/knowledgeClassification/publish',
    method: 'post',
    params: {
      id,
    },
  });
};

export const unpublish = id => {
  return request({
    url: '/position/knowledgeClassification/unPublish',
    method: 'post',
    params: {
      id,
    },
  });
};

export const getTime = (positionInstanceId, classificationId) => {
  return request({
    url: '/position/positionKnowledge/countTime',
    method: 'get',
    params: {
      positionInstanceId,
      classificationId,
    },
  });
};

export const addKnowledge = (knowledgeId, positionInstanceId) => {
  return request({
    url: '/position/positionKnowledge/save',
    method: 'post',
    data: {
      knowledgeId,
      positionInstanceId,
    },
  });
};

export const updateLevel = (id, level) => {
  return request({
    url: '/position/positionKnowledge/updateLevel',
    method: 'post',
    data: {
      id,
      level,
    },
  });
};

export const positionUser = positionInstanceId => {
  return request({
    url: '/position/positionUser/list',
    method: 'get',
    params: {
      positionInstanceId,
    },
  });
};

export const addUser = (positionInstanceId, userId, product) => {
  return request({
    url: '/position/positionUser/add',
    method: 'post',
    data: {
      positionInstanceId,
      userId,
      product,
    },
  });
};

export const getKnowledgeList = (positionInstanceId, classificationId, current, size, params) => {
  return request({
    url: '/position/positionKnowledge/list',
    method: 'get',
    params: {
      classificationId,
      positionInstanceId,
      current, size,
      ...params
    },
  });
};

export const getKnowledgeLists = (params, current, size) => {
  return request({
    url: '/position/knowledge/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    },
  });
};

export const removeKnowledge = ids => {
  return request({
    url: '/position/positionKnowledge/remove',
    method: 'post',
    params: {
      ids,
    },
  });
};
